package com.zhangkunhao.notes.controller;

import com.zhangkunhao.notes.bean.ButtonName;

import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

/**
 * 实现页面回退的功能
 *
 * @author 张坤浩
 */
public class CancelListener extends JFrame implements ActionListener {
    private JFrame openFrame;
    private JFrame closeFrame;

    public CancelListener(JFrame openFrame, JFrame closeFrame) {
        this.openFrame = openFrame;
        this.closeFrame = closeFrame;
    }

    @Override
    public void actionPerformed(ActionEvent e) {
        if (ButtonName.QUIT.equals(e.getActionCommand())) {
            this.openFrame.setVisible(true);
            this.closeFrame.setVisible(false);
        }
    }
}
